package com.teach.servlet.admin;

import com.alibaba.fastjson.JSON;
import com.teach.dao.SportingEventsDAO;
import com.teach.dao.impl.SportingEventsDAOImpl;
import com.teach.entity.CountryInfo;
import com.teach.entity.SportingEvents;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * -
 * 当前的项目名：medal-2022
 *
 * @author ZT
 * @data 2022/5/7 15:03
 **/
@WebServlet("/admin/SportingEvents-list.let")
public class SportingEventsListServlet extends HttpServlet {
    private SportingEventsDAO dao = new SportingEventsDAOImpl();

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.reset();
        response.setContentType("application/json;charset=UTF-8");
        try{
            List<SportingEvents> list = dao.select(0,999);
            response.getWriter().print(JSON.toJSONString(list));
        }catch (Exception ex){
            throw new ServletException(ex.getMessage(), ex);
        }
        response.flushBuffer();
    }
}
